#include <iostream>
#include <fstream>
#include <ctime>
using namespace std;
int main()
{
    const int LEN = 5000;
    int a1[LEN], a2[LEN], a3[LEN], flag = 0;
    ifstream fin ("m1_sorted.txt");
    for(int i=0; i < LEN; i++) fin >> a1[i];
    fin.close();

    ifstream ("m2_reverse.txt");
    for(int i=0; i < LEN; i++) fin >> a2[i];
    fin.close();
    ifstream ("m3_shuffle.txt");
    for(int i=0; i < LEN; i++) fin >> a3[i];
    fin.close();
    unsigned int t_start1 = clock();
    for (int i = 0; i < LEN; i++, flag = 0){
        for (int j = 0; j < LEN; j++){
            if (a1[j] > a1[j + 1]){
                int b = a1[j];
                a1[j] = a1[j + 1];
                a1[j + 1] = b;
                flag = 1;
            }
        }
        if (flag == 0) break;
    }
    unsigned int t_finish1 = clock();
    unsigned int t_work1 = t_finish1 - t_start1;
    cout<<"m1_sorted " << t_work1 << " milliseconds \n";
    unsigned int t_start2 = clock();
    for (int i = 0; i < LEN; i++, flag = 0){
        for (int j = 0; j < LEN; j++){
            if (a2[j] > a2[j + 1]){
                int b = a2[j];
                a2[j] = a2[j + 1];
                a2[j + 1] = b;
                flag = 1;
            }
        }
        if (flag == 0) break;
    }
    unsigned int t_finish2 = clock();
    unsigned int t_work2 = t_finish2 - t_start2;
    cout<<"m2_reverse " << t_work2 << " milliseconds \n";
    unsigned int t_start3 = clock();
    for (int i = 0; i < LEN; i++, flag = 0){
        for (int j = 0; j < LEN; j++){
            if (a3[j] > a3[j + 1]){
                int b = a3[j];
                a3[j] = a3[j + 1];
                a3[j + 1] = b;
                flag = 1;
            }
        }
        if (flag == 0) break;
    }
    unsigned int t_finish3 = clock();
    unsigned int t_work3 = t_finish3 - t_start3;
    cout<<"m3_shuffle " << t_work3 << " milliseconds \n";

    return 0;
}